import React from 'react';
import { AppRegistry, Dimensions } from 'react-native'; // 各种包一定要注意导入

// 跳转动画
import StackViewStyleInterpolator from 'react-navigation/src/views/StackView/StackViewStyleInterpolator';

console.disableYellowBox = true;
// console.warn("YellowBox is disabled.");

import { NativeModules } from 'react-native';
import { StackNavigator } from 'react-navigation';

NativeModules.Wxpay.registerApp("wxed051da706bfc9c6"); //向微信注册

global.ECourseConstant = {};
global.gScreen = {
  width: Dimensions.get('window').width,
  height: Dimensions.get('window').height
};

import RouterConfig from './src/RouterConfig';
import CommonStyle from './src/common/CommonStyle';
import CommonStyleSheet from './src/common/CommonStyleSheet';


global.CommonStyle = CommonStyle;
global.CommonStyleSheet = CommonStyleSheet;

// 打印提示信息
global.log = function(res,message) {
  console.log(res,message);
}

/* 为了注释烦人的调试提醒 */
console.ignoredYellowBox = true;//['Remote debugger'];


export default class Main extends React.Component {
  constructor(props) {
    super(props);
    var ECourseConstantJson = props.ECourseConstant;
    global.ECourseConstant = JSON.parse(ECourseConstantJson);
    // global.ECourseConstant.userInfo.studentId = '468774537639505920'; // TODO: 上线改成本地的
    // global.ECourseConstant.map["entryCourseId"]="484387698111545344";
    // global.ECourseConstant.map["entryLessonIds"]="484387737538002944";

    // global.log(global, "====global======");

  }
  render() {
    // global.ECourseConstant.eCourseFirstRouter="PayScreen";
    var FirstRouter = global.ECourseConstant.eCourseFirstRouter || "HomePage";
    if (RouterConfig.hasOwnProperty(FirstRouter)) {
      RouterConfig.FirstRouter = RouterConfig[FirstRouter];
    }

    const App = StackNavigator(RouterConfig, {
      navigationOptions: {
        header: null
      },
      // 跳转动画
      transitionConfig: () => ({
        screenInterpolator: StackViewStyleInterpolator.forHorizontal,
      }),
    });

    return (
      <App />
    )
  }

}
AppRegistry.registerComponent('eCourseApp', () => Main);